#include "../src/transform.h"

#include "gtest/gtest.h"
#include <math.h>

using namespace rst;

class TransformTest : public ::testing::Test {

};

TEST(transform, transform_test) {
	Transform zero(myEigen::Matrixf4x4(
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0
	));
	Transform t0;
	Transform t1(myEigen::Matrixf4x4(
		1, 0, 0, 0,
		0, 1, 0, 0,
		0, 0, 1, 0,
		0, 0, 0, 1
	));
	Transform t2(myEigen::Matrixf4x4(
		1.0000001f, 0, 0, 0,
		0, 1, 0, 0,
		0, 0, 1, 0,
		0, 0, 0, 1
	));
	Transform t3(myEigen::Matrixf4x4(
		1, 0, 0, -1,
		0, 1, 0, 0,
		0, 0, 1, 0,
		1, 0, 0, 1
	));

	EXPECT_TRUE(zero != t1);
	EXPECT_TRUE(zero * t1 == zero);
	EXPECT_TRUE(zero * t2 == zero);

	EXPECT_TRUE(t0 == t1);
	EXPECT_TRUE(t1 != t2);
	EXPECT_TRUE(t1 != t3);
	EXPECT_TRUE(t1 * t1 == t1);
	EXPECT_TRUE(t1 * t2 == t2);
	EXPECT_TRUE(t3 * t2 != t2);
}

TEST(transform, translate_test) {
	Transform zero(myEigen::Matrixf4x4(
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0
	));
	Transform t1(myEigen::Matrixf4x4(
		1, 0, 0, 0,
		0, 1, 0, 0,
		0, 0, 1, 0,
		0, 0, 0, 1
	));
	Transform t2(myEigen::Matrixf4x4(
		1, 0, 0, 1,
		0, 1, 0, 2,
		0, 0, 1, 3,
		0, 0, 0, 1
	));
	Transform t3(myEigen::Matrixf4x4(
		1, 0, 0, -1,
		0, 1, 0, -2,
		0, 0, 1, -3,
		0, 0, 0, 1
	));
	
	EXPECT_TRUE(zero != Translate(myEigen::Vector3f(0, 0, 0)));
	EXPECT_TRUE(t1 == Translate(myEigen::Vector3f(0, 0, 0)));

	EXPECT_TRUE(t2 == Translate(myEigen::Vector3f(1, 2, 3)));
	EXPECT_TRUE(t3 == Translate(myEigen::Vector3f(-1, -2, -3)));
	EXPECT_TRUE(t1 == Translate(myEigen::Vector3f(1, 2, 3)) * Translate(myEigen::Vector3f(-1, -2, -3)));
}

TEST(transform, scale_test) {
	EXPECT_TRUE(Transform() == Scale(1, 1, 1));
	EXPECT_TRUE(Transform() != Scale(1, 2, 3));
	EXPECT_TRUE(Scale(4, 10, 18) == Scale(1, 2, 3) * Scale(4, 5, 6));
	EXPECT_TRUE(Scale(-4, -10, -18) == Scale(-1, -2, -3) * Scale(4, 5, 6));

	EXPECT_TRUE(Transform() == Scale(myEigen::Vector3f(1,1,1)));
	EXPECT_TRUE(Transform() != Scale(myEigen::Vector3f(1, 2, 3)));
	EXPECT_TRUE(Scale(1, 2, 3) == Scale(myEigen::Vector3f(1, 2, 3)));
	EXPECT_TRUE(Scale(-4, -5, -6) == Scale(myEigen::Vector3f(-4, -5, -6)));

}
